package com.apes.enquiry.enquiry.model;

import com.apes.enquiry.brand.model.SpBrand;
import com.apes.enquiry.product.model.SpProduct;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.fileserver.File;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;
import java.util.Map;

/**
 * 类描述：报价结果
 *
 * @ClassName QuoteResult
 * @Description 描述
 * @Author wushilong
 * @Date 2023/3/20 10:44
 * @Version 1.0
 */

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = QuoteResult.CONST_TABLE_NAME)
public class QuoteResult extends BaseModel {

    public static final String CONST_TABLE_NAME = "sp_mas_quote_result";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "报价结果", padding = 8)
    @Comment("编码")
    private String id;

    @Column(name = "enquiry_id", length = 32, nullable = false)
    @Comment("询价单号")
    private String enquiryId;

    @Column(name = "quote_id", length = 32, nullable = false)
    @Comment("报价单id")
    private String quoteId;

    @Column(name = "enquiry_item", length = 32, nullable = false)
    @Comment("询价配件id")
    private String enquiryItem;

    @Column(name = "quote_item_id", length = 32)
    @Comment("询价配件id")
    private String quoteItem;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "quote_brand", referencedColumnName = "id")
    @Comment("报价品牌")
    private SpBrand quoteBrand;

    @Column(name = "not_tax_unit_price", length = 32, nullable = false)
    @Comment("裸价")
    private Double notTaxUnitPrice;

    @Column(name = "tax_unit_price", length = 32)
    @Comment("含税单价")
    private Double taxUnitPrice;

    @Column(name = "place_of_dispatch", length = 32, nullable = false)
    @Comment("货源")
    private Integer placeOfDispatch;

    @Column(name = "supplier_id", length = 32, nullable = false)
    @Comment("供应商id")
    private String supplierId;

    @Column(name = "state", length = 32, nullable = false)
    @Comment("状态")
    private String state;//00(现货), 10(订货), 20(终止)

    @Column(name = "note")
    @Comment("备注")
    private String note;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "product_id", referencedColumnName = "id")
    @Comment("商品列表")
    private SpProduct product;


    @File
    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "png", columnDefinition = "CLOB")
    @Comment("供应商图片")
    private String png;

    @Column(name = "purchase_information")
    @Comment("物流信息")
    private String purchaseInformation;

    @Column(name = "ZBQ")
    @Comment("质保期(月)")
    private Integer ZBQ;

    @Column(name = "price_no")
    @Comment("巴图鲁报价编号")
    private String priceNo;

    @Column(name = "expired_time")
    @Comment("巴图鲁询价过期时间")
    private Date expiredTime;

    @Column(name = "quote_date")
    @Comment("巴图鲁报价时间")
    private Date quoteDate;

    @Column(name = "latest_flag", columnDefinition = "number(1,0) default 1")
    @Comment("最新报价标识(0:否;1:是)")
    private Integer latestFlag;

    @Column(name = "quota_valid", columnDefinition = "number(1,0) default 1")
    @Comment("报价是否有效(0:否;1:是)")
    private int quotaValid;

    @Transient
    private Map quoteOE;

    @Column(name = "system")
    @Comment("系统报价")
    private String system;//系统报价

    @Transient
    private Boolean systemSign;//系统报价标记

    @Transient
    private String transientPicture;//闪电报价展示图片

    @Transient
    private Map extend;//商品扩展属性
}
